package edu.qd.learn.newchapter.chapter_thread.day02;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 学习一下池
 *
 * @author 布衣
 */
public class LearnPool extends Thread {


    @Override
    public void run() {
        System.out.println("开始==>" +currentThread().getName()+ this.getName());
        try {
            Thread.sleep(5);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
//        System.out.println("结束==>" + super.getName());
    }

    public static void main(String[] args) {

        for (int i = 0; i < 100; i++) {
            ExecutorService es = Executors.newSingleThreadExecutor();
            LearnPool t1 = new LearnPool();
            t1.setName("线程1");
            es.execute(t1);

            LearnPool t2 = new LearnPool();
            t2.setName("线程2");
            es.execute(t2);


            LearnPool t3 = new LearnPool();
            t3.setName("线程3");
            es.execute(t3);


            es.shutdown();
        }


    }


}
